@inject('appRepository', 'App\Repositories\AppRepository')
@php
    $tishi = $appRepository->getContentByColumn('ContentBlog',5,'课程页','购买提示');
    $tuijian = $appRepository->getRecommendCourseByCourseId($course->category_id,$course->id);
@endphp
@extends('layouts.app',['navShow'=>true])
@section('title',$course->name)
@section('content')
    <div class="container mt-2">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="/">首页</a></li>
                <li class="breadcrumb-item active" aria-current="page">{{$course->name}}</li>
            </ol>
        </nav>
        <div class="row p-3" style="background-color: #FFFFFF">
            <div class="col-xl-6 col-sm-12">
                <img src="{{$course->image_path}}" alt="" class="img-fluid"/>
            </div>
            <div class="col-xl-6 col-sm-12 course-body">
                <h3>{{$course->name}}</h3>
                <p class="desc">课程分类：{{$course->category_name}} 年级：{{$course->grade_name}}</p>
                <span class="btn btn-outline-primary btn-sm my-1">视频课</span>
                <p class="desc">主讲老师：{{$course->speaker_name}}</p>
                <p class="desc">订阅人数：200人</p>
                {{--<button type="button" class="btn btn-warning mt-5">立即购买</button>--}}
            </div>
        </div>
        <div class="row  my-3 ">
            <div class="col mr-3 ">
                <div class="row body p-3" style="background-color: #FFFFFF">
                    <div class="col">
                        <ul class="nav nav-tabs nav-course" id="myTab" role="tablist">
                            <li class="nav-item">
                                <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab"
                                   aria-controls="home" aria-selected="true">课程介绍</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab"
                                   aria-controls="profile" aria-selected="false">课程目录（共{{count($course->lessons)}}节）</a>
                            </li>
                        </ul>
                        <div class="tab-content" id="myTabContent">
                            <div class="tab-pane fade show active p-3" id="home" role="tabpanel"
                                 aria-labelledby="home-tab">
                                {!! $course->synopsis !!}
                            </div>
                            <div class="tab-pane fade p-3" id="profile" role="tabpanel" aria-labelledby="profile-tab">
                                <ul class="list-group lessons-list list-group-flush">
                                    @foreach($course->lessons as $item)
                                        <li class="list-group-item d-flex justify-content-between align-items-center">
                                            {{$item->name}}

                                            @if($item->status === 'ready')
                                                <span class="primary-desc">直播未开始</span>
                                            @elseif($item->status === 'live')
                                                <a target="_blank" href="{{url('/live/broadcast',['lesson'=>$item->id])}}">
                                                    <span class="btn btn-outline-primary">观看直播</span>
                                                </a>
                                            @else
                                                <a class="btn btn-outline-primary"  target="_blank" href="{{url('/live/play',['lesson'=>$item->id])}}">
                                                    观看回放
                                                </a>
                                            @endif
                                        </li>
                                    @endforeach
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                @if($tishi&&count($tishi)>0)
                    <div class="row mt-3 p-3" style="background-color: #FFFFFF">
                        <div class="col-xl-8 col-sm-12">
                            <div class="content-title mt-3">
                                <p>购买提示</p>
                            </div>
                            <div class="tishi-body mt-4">
                                @foreach($tishi as $key => $item)
                                    <div class="media">
                                        <div class="media-body">
                                            <a href="{{url('content',['contentId'=>$item->id])}}">

                                                <h5 class="tishi-title mt-0">{{$key+1}}、{{$item->title}}</h5>
                                            </a>
                                            {{$item->keywords}}
                                        </div>
                                    </div>
                                @endforeach
                            </div>
                        </div>
                    </div>
                @endif
            </div>
            <div class="col-xl-3  col-sm-12  ">
                <div class="row p-3" style="background-color: #FFFFFF">
                    <div class="d-flex justify-content-center">
                        <div class="speaker-desc">
                            <img class="head " src="{{$course->speaker->teacher->photo}}" alt="">
                            <div class="name">{{$course->speaker_name}}</div>
                            <div class="profile">{{$course->speaker->teacher->profile}}</div>
                        </div>
                    </div>
                </div>
                <div class="row p-3 mt-3" style="background-color: #FFFFFF">
                    <div class="content-title mt-2 col-12">
                        <p>热门推荐</p>
                    </div>
                    <div class="tuijian-body mt-3 col-12 row">
                        @foreach($tuijian as $key => $item)
                            <div class="col-12 mt-1">
                                <a class="tuijian-item" href="/course/{{$item->id}}/course-detail"> {{$key+1}}
                                    . {{$item->name}}</a>
                            </div>
                        @endforeach
                    </div>
                </div>
            </div>
        </div>

    </div>
@endsection